package com.pks.insurance.servlet;

import java.io.File;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.xml.DOMConfigurator;

/**
 * Servlet implementation class Log4jServlet
 */
public final class Log4jServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see Servlet#init(ServletConfig)
	 */
	@Override
	public void init(ServletConfig config) throws ServletException {
		// String prefix = config.getServletContext().getRealPath("/");
		// System.setProperty("rootPath",prefix);
		String logFile = config.getInitParameter("log4j-init-file");
		String realPath = config.getServletContext().getRealPath(logFile);
		File file = new File(realPath);
		// if the log4j-init-file is not set, then no point in trying
		if (logFile != null) {
			// PropertyConfigurator.configure(file.getAbsolutePath());
			DOMConfigurator.configure(file.getAbsolutePath());
		}
	}

}
